{extend name="layout" /}
{block name="body"}
  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-toolbar d-flex flex-column flex-md-row">
          <div class="toolbar-btn-action">
            {if condition="check_rule('admin/data_model/index', [1,2,3])"}
            <a class="btn btn-default m-r-5" href="{:url('data_model/index')}"><i class="mdi mdi-replay"></i> 返回</a>
            {/if}
            {if condition="check_rule('admin/data_model/addField', [1,2,3])"}
            <a class="btn btn-primary m-r-5" href="{:url('addField', 'model_id='.$model_id)}"><i class="mdi mdi-plus"></i> 新增</a>
            {/if}
            {if condition="check_rule('admin/data_model/setFieldStatus', [1,2,3])"}
            <a class="btn btn-success m-r-5 ajax-post confirm" href="{:url('setFieldStatus', 'status=1')}" target-form="ids"><i class="mdi mdi-check"></i> 启用</a>
            <a class="btn btn-warning m-r-5 ajax-post confirm" href="{:url('setFieldStatus', 'status=0')}" target-form="ids"><i class="mdi mdi-block-helper"></i> 禁用</a>
            {/if}
          </div>
          
          <form class="search-bar ml-md-auto" method="get" action="{:url('fieldList', 'model_id='.$model_id)}" role="form">
            <input type="hidden" name="search_field" id="search-field" value="title" />
            <div class="input-group ml-md-auto">
              <div class="input-group-prepend">
                <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="search-btn">
                {notempty name='search_field'}{:get_search_type($search_field)}{else /}名称{/notempty}
                </button>
                <div class="dropdown-menu">
                  <a class="dropdown-item" href="javascript:void(0)" data-field="title">名称</a>
                  <a class="dropdown-item" href="javascript:void(0)" data-field="en_title">英文名</a>
                </div>
              </div>
              <input type="text" class="form-control" name="keyword" placeholder="请输入搜索关键词" value="{$keyword}">
            </div>
          </form>
        </div>
        <div class="card-body">
          
          <div class="table-responsive">
            <table class="table table-bordered">
              <thead>
                <tr>
                  <th>
                    <div class="custom-control custom-checkbox">
                      <input type="checkbox" class="custom-control-input" id="check-all">
                      <label class="custom-control-label" for="check-all"></label>
                    </div>
                  </th>
                  <th>编号</th>
                  <th>字段名称</th>
                  <th>字段英文名</th>
                  <th>类型</th>
                  <th>创建时间</th>
                  <th>排序</th>
                  <th>显示</th>
                  <th>状态</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
                {volist name="list" id="vo"}
                <tr>
                  <td>
                    <div class="custom-control custom-checkbox">
                      <input type="checkbox" class="custom-control-input ids" name="ids[]" value="{$vo.id}" id="ids-{$vo.id}">
                      <label class="custom-control-label" for="ids-{$vo.id}"></label>
                    </div>
                  </td>
                  <td>{$vo.id}</td>
                  <td>{$vo.title}</td>
                  <td>{$vo.en_title}</td>
                  <td>{:get_field_type($vo.type)}</td>
                  <td>{$vo.create_time}</td>
                  <td>{$vo.sort}</td>
                  <td>{:get_show_type($vo.show)}</td>
                  <td>{:show_status_op($vo.status)}</td>
                  <td>
                    <div class="btn-group">
                      {if condition="check_rule('admin/data_model/editField', [1,2,3])"}
                      <a class="btn btn-xs btn-default" href="{:url('editField', 'id='.$vo['id'])}" title="编辑" data-toggle="tooltip" data-original-title="编辑"><i class="mdi mdi-pencil"></i></a>
                      {/if}
                      {if condition="check_rule('admin/data_model/deleteField', [1,2,3])"}
                      <a class="btn btn-xs btn-default ajax-get confirm" href="{:url('deleteField', 'ids='.$vo['id'])}" title="删除" data-toggle="tooltip" data-original-title="删除"><i class="mdi mdi-window-close"></i></a>
                      {/if}
                    </div>
                  </td>
                </tr>
                {/volist}
              </tbody>
            </table>
          </div>
          {$list|raw}
 
        </div>
      </div>
    </div>
    
  </div>
{/block}